package com.yowasa.xiuxian.engine.travel.adventure;

import com.google.common.collect.Sets;
import com.yowasa.xiuxian.engine.travel.AdventureInterface;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.MapEnum;
import com.yowasa.xiuxian.entity.enums.RefreshType;
import com.yowasa.xiuxian.service.helper.ResourceHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * 九星连珠奇遇 60年至多触发一次
 * 刷新地图资源
 */
@Component
public class JiuXingLianZhu implements AdventureInterface {
    @Autowired
    private ResourceHelper resourceHelper;

    /**
     *
     * @param user
     * @return
     */
    @Override
    public boolean limitCheck(UserBO user) {
        return resourceHelper.checkHaveResource(user.getGuildId(), this.getClass().getName(), RefreshType.LOCK_TIME);

    }

    /**
     * 全地图可触发
     *
     * @return
     */
    @Override
    public Set<MapEnum> limitMaps() {
        return Sets.newHashSet(MapEnum.values());
    }

    @Override
    public String exec(UserBO user) {
        resourceHelper.refreshJiuXing();
        resourceHelper.lockResource(user.getGuildId(), this.getClass().getName(), 60 * 360);
        return "你夜观天象，发现一排九星，在天幕中穿梭而过，交相辉映，星光闪耀。这便是弈天门测算师所预言的“九星连珠”现象（地图资源刷新）";
    }


}
